Switch Properties

Description

Switch controls are ideal for toggling between two states, such as 'Yes' or 'No, in which repeated entry into a field might become onerous.

images/switch.png
A Switch Control

Sub-theme

Sub-themes allow you to tweak the styling on control types within a component without having to change the main theme of the component. This approach is often preferable to manually changing the styling on individual controls by changing individual style settings. If you leave this property blank the default ('base') sub-theme is used.

A sub-theme is a variation on the main theme or 'style' of a component. This main style is defined in the Style name property in the UX Properties section. Once a style for the component is selected, this will determine the available sub-themes for a given control type. You can create your own sub-themes. For information on how to do this visit the 'Local sub-theme definitions - Javascript' property page in the UX Properties section.

Control container Width

The Control container Width property specifies the width of the container that contains the switch control.

This property was previously named the "Width" property in Alpha Anywhere 4.5.5.0 and prior.

Switch Width

The width of the Switch control within the control's container. The Switch Width is defined using CSS syntax. Default is 100px.

images/length.png
Switch width set to .75in
images/length1.png
Switch width set to 12cm
images/length2.png
Switch width set to 300px

Flow

Flow specifies the control's 'flow' direction. This can be left-to-right (LRT) or right-to-left (RTL).

images/flow.png

Left to Right (LTR)

If LTR is selected, when the switch control is 'off' the button will be on the left.

images/ltr.png
LTR in 'On' position
images/ltr2.png
LTR in 'Off' position

Right to Left (RTL)

If RTL is used, when the switch is off then the button will be on the right.

images/ltr2.png
RTL in 'On' position
images/ltr.png
RTL in 'Off' position

Text for 'on' state

This optional property causes text to be displayed when the switch is in the 'on' state. Because the text is often centered in the middle of the control it might be necessary to increase the width of the switch control in order to see it.

images/text.png
Setting the text to read 'True'
images/text1.png
The text for the on state set to read 'True'

Text for 'off' state

This optional property causes text to be displayed when the switch is in the 'off' state. Because the text is often centered in the middle of the control it might be necessary to increase the width of the switch control in order to see it.

images/text3.png
Setting the text to read 'False'
images/text4.png
Text for the 'off' state now reads 'False'

'On' value

The stored value for the on state for a character type Switch control.

If a Switch control's underlying data a "Character" Type, the 'On' value property can be used to specify the Switch control's value when it is in the 'On' state.

OnSelect event

Specify JavaScript to run when the Switch control's state changes.

The Switch builder allows you to specify an OnSelect event which is fired when the state of the switch is changed. The JavaScript in the OnSelect event can reference the value of the switch using the this variable. For example:

var state = this.value;
// test the value for a Switch control bound to a Logical data type:
if (state == true) {
    alert("Switch is on!");
} else {
    alert("Switch is off!");
}